<template>
  <div>
    <el-form ref="form" :model="form" label-width="120px" size="small">
      <slot name="form-item-task-name" :model="form" field="name">
        <el-form-item label="跳转类型">
          <el-select v-model="form.skipType">
            <el-option sel label="审批通过" value="PASS"/>
            <el-option label="驳回" value="REJECT"/>
          </el-select>
        </el-form-item>
      </slot>
      <slot name="form-item-task-name" :model="form" field="name">
        <el-form-item label="跳转条件">
          <el-input v-model="form.skipCondition" placeholder="跳转条件"/>
        </el-form-item>
      </slot>
    </el-form>
  </div>
</template>

<script>
import {listRole} from "@/api/system/role";
import {listUser} from "@/api/system/user";
import {listDept} from "@/api/system/dept";

export default {
  name: "Between",
  props: {
    value: {
      type: Object,
      default () {
        return {}
      }
    },
  },
  data () {
    return {
      form: this.value,
      // 是否禁用表单
      disabled: false,
      attrKey: '',
      field: this.value.field || {},
      groupOptions: [],
    }
  },
  created() {
    if (this.$route.query.disabled == 'true') {
      this.disabled = true
    }
    this.getPermissionFlag();
  },
  methods: {
    /** 选择角色权限范围触发 */
    getPermissionFlag() {
      listRole().then(response => {
        let groupOption = {
          label: '角色',
          options: response.rows.map(item =>{
              return {
                value: 'role:' + item.roleId,
                label: item.roleName
              }
            }
          )
        }
        this.groupOptions.push(groupOption);
      });
      listUser().then(response => {
        let groupOption = {
          label: '用户',
          options: response.rows.map(item =>{
              return {
                value: 'user:'+ item.userId,
                label: item.nickName
              }
            }
          )
        }
        this.groupOptions.push(groupOption);
      });
      listDept().then(response => {
        let groupOption = {
          label: '部门',
          options: response.data.map(item =>{
              return {
                value: 'dept:' + item.deptId,
                label: item.deptName
              }
            }
          )
        }
        this.groupOptions.push(groupOption);
      });
    },
  }
}
</script>

<style scoped>

</style>
